﻿using System.Web.UI.WebControls;
using Ue.Framework.Web.WebControls;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain.Shops;
using Ue.Qcdz.Domain.ShopSinglePages;
using Ue.Qcdz.Domain;
namespace Ue.Qcdz.UI.Controls
{
    /// <summary>
    /// 店铺单页
    /// </summary>
    public class ShopSinglePageShow : SkinnedControl
    {
        private Literal ltrTitle;
        private Literal ltrImageUrl;
        private Literal ltrContent;
        private Literal ltrRemark;
        public string ImgUrl = string.Empty;
        protected override string GetSkinFileName()
        {
            return "";
        }
        public string Title
        {
            set;
            get;
        }
        protected override void InitializeSkin(System.Web.UI.Control skin)
        {
            ltrTitle = skin.FindControl<Literal>("ltrTitle");
            ltrImageUrl = skin.FindControl<Literal>("ltrImageUrl");
            ltrContent = skin.FindControl<Literal>("ltrContent");
            ltrRemark = skin.FindControl<Literal>("ltrRemark");
            BindToControl();
        }
        private void BindToControl()
        {
            ShopSinglePage model = ShopSinglePageService.GetShopSinglePage(SiteContext.GetSiteContext().SinglePageId);
            if (model == null)
            {
                Shop shop = Domain.SiteContext.GetSiteContext().Shop;
                model = ShopSinglePageService.GetSinglePage(this.Title, shop);
            }
            if (model != null)
            {
                if (model == null) return;
                if (this.ltrTitle != null)
                    ltrTitle.Text = this.Page.Title = model.Title;
                if (this.ltrImageUrl != null)
                    ltrImageUrl.Text = model.ImageUrl;
                if (this.ltrContent != null)
                    ltrContent.Text = model.Content;
                if (this.ltrRemark != null)
                    ltrRemark.Text = model.Remark;
                //
                ImgUrl = model.ImageUrl;
            }
        }
    }
}
